***************************************************************************************************
********************* Lasse Laustsen, 2021; Advances in Political Psychology***********************
************* Candidate Evaluations through the Lens of Adaptive Followership Psychology **********
***************************************************************************************************

*************************** Recodings of used variables *******************************************

*** Creates country identifier: "1" = Ukraine; "2" = Polen
tab country
label define countryLB 1 "Ukraine" 2 "Poland"
label values country countryLB


**** Background variables and demographics
*** Participant sex; "1" = female; "2" = male
clonevar sex = qa

*** Participant age
clonevar age = qb

*** Participant education
generate education = .
replace education = 1 if qe == 1 & country == 1
replace education = 1 if qe == 1 & country == 2
replace education = 1 if qe == 2 & country == 1
replace education = 1 if qe == 2 & country == 2
replace education = 2 if qe == 3 & country == 1
replace education = 2 if qe == 3 & country == 2
replace education = 3 if qe == 4 & country == 1
replace education = 3 if qe == 4 & country == 2
replace education = 4 if qe == 5 & country == 1
replace education = 4 if qe == 5 & country == 2
replace education = 5 if qe == 6 & country == 1
replace education = 5 if qe == 6 & country == 2

*Labels for education
label define educationLB 1 "Primary school or High school" 2 "Basic Vocational school" 3 "Secondary school" 4 "Bachelor's Degree" 5 "Master degree/Science degree and Doctorate"
label values education educationLB


**** Individual difference measures
*** Social Dominance Orientation (higher value = higher SDO)
* Recodes such that items have same direction
recode q1_3 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q1_4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q1_7 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q1_8 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
alpha q1_1 q1_2 q1_3 q1_4 q1_5 q1_6 q1_7 q1_8, item

* Creates SDO measure on 0-1 scale
egen sdo = rowmean(q1_1 q1_2 q1_3 q1_4 q1_5 q1_6 q1_7 q1_8)
generate SDO=(sdo-1)/6

** Creates sub-scale measures for SDO-Dominance and SDO-Antiegalitarianism on 0-1 scales
*SDO-D
bys country: alpha q1_1 q1_2 q1_3 q1_4
gen SDO_D = (q1_1+q1_2+q1_3+q1_4-4)/24
bys country: summ SDO_D

*SDO-E
bys country: alpha q1_5 q1_6 q1_7 q1_8
gen SDO_E = (q1_5+q1_6+q1_7+q1_8-4)/24
bys country: summ SDO_E

*** Rightwing Authoritarianism (higher value = higher RWA)
* Recodes such that items have same direction
recode q2_1 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q2_2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q2_6 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
recode q2_7 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
alpha q2_1 q2_2 q2_3 q2_4 q2_5 q2_6 q2_7 q2_8, item

* Creates RWA measure on 0-1 scale based on all 8 items
egen rwa = rowmean(q2_1 q2_2 q2_3 q2_4 q2_5 q2_6 q2_7 q2_8)
generate RWA = (rwa-1)/6

* Creates RWA measure without item q2_3 because this improves Cronbach's alpha
alpha q2_1 q2_2 q2_4 q2_5 q2_6 q2_7 q2_8, item

egen rwa_7 = rowmean(q2_1 q2_2 q2_4 q2_5 q2_6 q2_7 q2_8)
generate RWA_7 = (rwa_7-1)/6


*** Political ideology: Left-right self-placement on 0-1 scale
generate left_right = q8/10
summ left_right


*** Experimental conditions (Contextual variable)
generate context =.
replace context = 2 if q6a == 1
replace context = 2 if q6a == 2
replace context = 3 if q6b == 1
replace context = 3 if q6b == 2
replace context = 1 if q6c == 1
replace context = 1 if q6c == 2

*Labels for contextual condition
label define contextLB 1 "Neutral" 2 "Cooperation/Dam" 3 "Conflict/War"
label values context contextLB


**** Dependent variable: Face choice
*** Choice of face ("0" = non-dominant face; "1" = dominant face)
generate choice =.
replace choice = 1 if q6a == 1
replace choice = 1 if q6b == 1
replace choice = 1 if q6c == 1
replace choice = 0 if q6a == 2
replace choice = 0 if q6b == 2
replace choice = 0 if q6c == 2

*Labels for choice of face
label define choiceLB 0 "Non-dominant" 1 "Dominant" 
label values choice choiceLB



*************** Results reported for Individual Difference Prediction, Intergroup Conflict ***********************
** Descriptive statistics for the used variables
bys country: summ SDO SDO_D SDO_E RWA left_right

**** Tests whether SDO-D, SDO-E, RWA or ideology is the stronger individual-level predictor of choice of dominant face
** Ukraine
logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==1

** Poland
logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==2


******************************** Figure 3 in article ********************************************
logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==1
margins, dydx(SDO_D SDO_E left_right RWA)
marginsplot, recastci(rcap) ciopts(lpattern(solid)) recast(bar) yline(0) xlabel() ylabel(-0.3 (0.1) 0.4) ///
xtitle(Individual diff. measures) ytitle(pred. prob. dominant face) title("Panel A: Ukraine") ///
name(Ukraine, replace)

logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==2
margins, dydx(SDO_D SDO_E left_right RWA)
marginsplot, recastci(rcap) ciopts(lpattern(solid)) recast(bar) yline(0) xlabel() ylabel(-0.3 (0.1) 0.4) ///
xtitle(Individual diff. measures) ytitle(pred. prob. dominant face) title("Panel B: Poland") ///
name(Poland, replace)

graph combine Ukraine Poland, cols(1) 


******************************** Table S.2.1 in Supplementary Materials ********************************************
eststo clear
logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==1
eststo Ukraine
logit choice c.SDO_D c.SDO_E c.RWA c.left_right i.context i.sex c.age i.education if country==2
eststo Poland

esttab
